package com.siwei.mes.controller.common;

import com.siwei.mes.common.result.ApiResult;
import com.siwei.mes.common.result.Json;
import com.siwei.mes.common.validator.AddGroup;
import com.siwei.mes.entity.system.AppVersion;
import com.siwei.mes.service.system.AppVersionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * app版本号相关
 *
 * @author linzi
 * @since 2024-01-29 22:26:24
 */
@Api(value = "app版本号")
@RestController
@RequestMapping("appVersion")
public class AppVersionController {
    @Resource
    private AppVersionService appVersionService;

    @ApiOperation(value = "新增app版本号")
    @PostMapping("/create")
    public Json create(@RequestBody @Validated(AddGroup.class) AppVersion entity) {
        return Json.succ().data(ApiResult.addColumn("id", appVersionService.create(entity)));
    }

    //@AnonymousAccess
    @ApiOperation(value = "根据平台获取版本号")
    @GetMapping("getVersion")
    public Json getVersion(@RequestParam("platform") String platform) {
        String lowerCase = platform.toLowerCase();// 全部转小写
        return Json.succ().data(appVersionService.getVersion(lowerCase));
    }

}
